var { Plot } = require("../Plot.js")
var { Point } = require("../Point")

var cdom = document.getElementById("myCanvas")
// @ts-ignore
var plot = new Plot(cdom);
var md = require("../html5-canvas-particle-effect/js/points.12.9")

md.refesh = function () {
	plot.drawList(md.list)
}

var NodeSet = require("../nodeSet/NodeSet")


cdom.onmousemove = /**
 * @param {MouseEvent} e
 */
	function (e) {
		if (cdom.stat == "click" && cdom.n != undefined) {
			var view = Plot.viewv;
			var n = cdom.n
			md.list[n].x = view.left + e.clientX * view.k1;
			md.list[n].y = view.top + e.clientY * view.k1;
		}
		// if (CanvasDom.stat == "click") {
		// 		nodeArr[select_i].y = this.clientHeight / 2 - e.pageY
		// 		nodeArr[select_i].x = e.pageX - this.clientWidth / 2
		// 	drawAction && drawAction()
		// }
	};

cdom.onmousedown = function (e) {
	var view = Plot.viewv;
	// @ts-ignore
	var n = NodeSet.getSelect(md.list, { x: view.left + e.clientX * view.k1, y: view.top + e.clientY * view.k1 });
	cdom.stat = "click";
	cdom.n = n;
};


cdom.onmouseup = function () {
	cdom.stat = "unclick";
};
global.cdom = cdom;